package com.micromsg.basic.config;

import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

@Component
public class ThreadPoolConfig {

    @Bean
    public ThreadPoolExecutor fixedThreadPool() {
//        ExecutorService executorService = Executors.newFixedThreadPool(10);

        int nThreads = 10;
        ThreadPoolExecutor poolExecutor = new ThreadPoolExecutor(nThreads, nThreads,
                0L, TimeUnit.MILLISECONDS,
                new LinkedBlockingQueue<Runnable>());

//        Thread thread = new Thread();
//        Future<?> submit = fixedThreadPool.submit(thread);

        return poolExecutor;
    }
}
